import 'package:dio/dio.dart';
import '../../../common/http/global.dart';
class Api {
  Dio dio = Dio();
  Future<List> getHome<T>([bool showLoading = true]) async {
    try {
      var response = await dio.get('$baseUrl/homeApp/getHome');
      dismissLoadingIfNeeded(showLoading);
      if (response.data['data'] is Map) {
        List<Map<String, dynamic>> list = List<Map<String, dynamic>>.from(
            response.data['data']['book']['list']
                .map((e) => e is Map ? e : {})); // 将元素转换为Map类型，若不是则使用空Map
        return list;
      }
      return [];
    } catch (e) {
      dismissLoadingIfNeeded(showLoading);
      print('Error occurred during sendCode: $e');
      rethrow;
    }
  }
}
